python - How to catch and print the full exception traceback without halting/exiting the program? - Stack Overflow

import traceback
import sys

try:
    do_stuff()
except Exception:
    print(traceback.format_exc())
    # or
    print(sys.exc_info()[2])